package study.chapter02.innerclass;

public class Outer2 {
    public static void main(String[] args) {
        IMessageWrapper.send(new MyMessage(), new MyChannel());
    }
}

interface IMessageWrapper{
    static interface IMessage{
        //获取消息
        String getContent();
    }

    static interface IChannel{
        boolean connect();
    }

    public static void send(IMessage msg, IChannel channel){
        if (channel.connect()){
            System.out.println(msg.getContent());
        }else {
            System.out.println("无法连接通信");
        }
    }

}

class MyMessage implements IMessageWrapper.IMessage{

    @Override
    public String getContent() {
        return "hello world";
    }
}

class MyChannel implements IMessageWrapper.IChannel{

    @Override
    public boolean connect() {
        return true;
    }
}
